package org.lee.config;

import com.google.common.collect.Lists;
import org.lee.bean.Klass;
import org.lee.bean.School;
import org.lee.bean.Student;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lizhe
 */
@Configuration
@ConditionalOnProperty(prefix = "my-spring", name = "enable", havingValue = "true")
public class MyConfiguration {

    @Bean
    public Student student100() {
        return new Student(100, "小李",null,null);
    }

    @Bean
    public Klass klass() {
        Klass klass = new Klass();
        klass.setStudents(Lists.newArrayList(student100()));
        return klass;
    }

    @Bean
    public School school() {
        School school = new School();
        school.setClass1(klass());
        school.setStudent100(student100());
        return school;
    }

}
